<template>
	<view class="content">
		<view class="logo">
			<image src="../../static/blogo.png" mode=""></image>
		</view>
		<view class="code">
			<view class="my">
				<view>我的邀请码</view>
				<view>{{code}}</view>
				<view>好友注册时填写邀请码</view>
			</view>
			<view class="qr_code">
				<canvas style="width:150px;height:150px;" canvas-id="couponQrcode"></canvas>
			</view>
		</view>
		
	</view>
</template>
<script>
	const qrCode = require('@/js_sdk/qrcode/weapp-qrcode.js')
	export default {
		data() {
			return {
				url:'',
				code:'',
			}
		},
		onReady() {
			
		},
		onLoad(e) {
			//console.log(e)
			this.code = e.code
			this.getUserInfo()
		},
		methods: {
			// 二维码生成工具
			couponQrCode(url,e) {
				new qrCode('couponQrcode', {
					//text: `http://192.168.31.135:8080/register/#/registered/${e}`,
					text: `${url}register/#/registered/${e}`,
					width: 150,
					height: 150,
					colorDark: "#333333",
					colorLight: "#FFFFFF",
					correctLevel: qrCode.CorrectLevel.H
				})
			},
			//获取用户信息
			getUserInfo(){
				this.$http({
					url:this.$api.index_getAll,
					method:'POST',
					success:res=>{
						this.couponQrCode(res.data.registerurl,this.code)
					}
				})
			},
		}
	}
</script>
<style lang="less" scoped>
	.content{
		width: 100%;
		height: 100vh;
		background: url(../../static/yqhy.png)center/cover no-repeat;
		.logo{
			width: 600rpx;
			height: 287rpx;
			margin: 0 auto;
			padding: 40rpx 0;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.code{
			position:absolute;
			left: 10%;
			top:300rpx;
			background-color:rgba(0,0,0,0.4);
			border-radius: 15rpx;
			padding: 40rpx 0;
			text-align: center;
			width: 80%;
			color: #FFFFFF;
			.qr_code {
				width: 165px;
				height: 165px;
				padding: 10rpx;
				display: flex;
				margin: 30rpx auto;
				align-items: center;
				justify-content: center;
				background-color: #FFFFFF;
			}
			.my{
				
				font-size: 12px;
				view:nth-child(2){
					font-size: 30px;
					font-weight: 600;
					padding: 10rpx 0;
				}
			}
			
		}
	}
</style>